import { createStore } from 'vuex'

export default createStore({
    state: {
        isStylePc: true, //pc还是移动，样式判断 true:pc  fasel:移动
        icarNewsScrollY: 0,
        icarNewsScrollY_m: 0,
        disableLoading: false
    },

    actions: {
        // 设置 pc样式还是移动样式
        setStylePc(context, is) {
            context.commit("setStylePc", is);
        },
        // pc
        setIcarNewsScrollY(context, icarNewsScrollY) {
            context.commit("setIcarNewsScrollY", icarNewsScrollY);
        },
        // mobile
        setIcarNewsScrollY_m(context, icarNewsScrollY_m) {
            context.commit("setIcarNewsScrollY_m", icarNewsScrollY_m);
        },
    },
    mutations: {
        // 设置 pc样式还是移动样式
        setStylePc(state, is) {
            if (state.isStylePc != is) {
                state.isStylePc = is;
            }
        },
        // 设置pc公司资讯记录滚动位置
        setIcarNewsScrollY(state, icarNewsScrollY) {
            state.icarNewsScrollY = icarNewsScrollY;
        },

        // 设置mobile公司资讯记录滚动位置
        setIcarNewsScrollY_m(state, icarNewsScrollY_m) {
            state.icarNewsScrollY_m = icarNewsScrollY_m;
        },

        setDisableLoading(state, is) {
            state.disableLoading = is;
        }
    },
})
